/*
 * Copyright (c) 2012 Jonathan Tyers
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.org.uplink.configproxy.integration;

import static org.junit.Assert.assertEquals;

import org.apache.commons.configuration.XMLConfiguration;
import org.junit.Before;
import org.junit.Test;

import uk.org.uplink.configproxy.ConfigProxyFactory;
import uk.org.uplink.configproxy.ConfigValue;

/**
 * Integration Test to exercise a number of features
 * @author Steve Ash
 */
public class IntegrationTest1 {

	private Simple1 proxy;

	// no config proxy annotation
	static interface Simple1 {

		String getMyConfig1();

		@ConfigValue(key = "myConfig2")
		String myConfig2Value();
	}

	@Before
	public void setUp() throws Exception {
		proxy = new ConfigProxyFactory().createConfigProxy(Simple1.class,
				new XMLConfiguration("integration1.xml"));
	}

	@Test
	public void testWithConfigValueAnnotation() throws Exception {
		assertEquals("456", proxy.myConfig2Value());
	}

	@Test
	public void testWithoutConfigValueAnnotation() throws Exception {
		assertEquals("123", proxy.getMyConfig1());
	}
}
